package com.miui.systemui.tools;

import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import java.awt.Toolkit
import javax.swing.SwingUtilities
import javax.swing.WindowConstants


class Figma2xmlAction : AnAction() {

    override fun actionPerformed(e: AnActionEvent) {
        // 创建并显示对话框，传递上次的选择
        SwingUtilities.invokeLater {
            val dialog = Figma2xmlDialog()
            dialog.title = "figma 转 xml"
            dialog.pack()
            dialog.isVisible = true

            val screenSize = Toolkit.getDefaultToolkit().screenSize
            // 获取对话框尺寸
            val dialogSize = dialog.size
            // 设置对话框位置到屏幕中心
            val x = (screenSize.width - dialogSize.width)
            val y = (screenSize.height - dialogSize.height)
            dialog.setLocation(x, 0)
            dialog.show()
        }
    }
}

